let connection = require('../database/connection');

async function update_message(sql,arg,is_message){
    arg.push(is_message);
    let db_res = await connection.dbQuery(sql,arg);
    if(db_res.err===0){
        let id = db_res.result.insertId;
        sql = "select DATE_FORMAT(time,\"%Y-%m-%d %H:%i:%S\") as time from message where id = ?";
        arg = [];
        arg.push(id);
        let db_res_time = await connection.dbQuery(sql,arg);
        return db_res_time.result[0].time;
    }
}

module.exports = {
    update_message
}